$(function () {
    let id = localStorage.getItem("temp");
    findByRoomId(id);
});
/**
 * 首页或者订单页面点击图片后跳转到房间详情页面并显示点击图片的详细数据
 */

/*通过此方法进行查询*/
function findByRoomId(id) {
    let result = myAjax('/findRoomDetails', 'get', {id: id});
    let data = result.list;
    $("#shangyitiao").html('<span>上一条：无</span>');
    $("#xiayitiao").html('<span>下一条：无</span>');
    for (let i = 0; i < data.length; i++) {
        //根据数据的id进行判断 进行不同操作
        if (data[i].roomId < id) {
            $("#shangyitiao").html('<span onclick="findByRoomId(' + data[i].roomId + ')">上一条：' + data[i].roomTitle + '</span>');
        } else if (data[i].roomId == id) {
            console.log("----------------");
            setDetails(data[i]);
        } else {
            $("#xiayitiao").html('<span onclick="findByRoomId(' + data[i].roomId + ')">下一条：' + data[i].roomTitle + '</span>');
        }
    }
}

function setDetails(data) {
    $("#type").html(data.roomTitle);
    $("#room-picture").html('<img src="'+data.roomPhoto+'">');
    $("#market-price").html(data.roomPrice);
    $("#price").html(data.roomPrice);
}
function shuaxin() {
 location.assign("/html/roomDetails.html");
}